package com.example.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.dto.problem.ProblemQueryRequest;
import com.example.pojo.response.Result;
import com.example.pojo.vo.problem.ProblemVo;
import com.example.service.ProblemService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@Tag(name = "题目管理")
@RestController
@RequestMapping("/problem")
public class ProblemController {

    @Autowired
    private ProblemService problemService;

    /**
     * 获取所有题目列表
     * @return Result<Page<ProblemVo>>
     */
    @Operation(summary = "分页获取题目列表")
    @PostMapping("/listAll")
    public Result<Page<ProblemVo>> listAll(@RequestBody ProblemQueryRequest problemQueryRequest) {
        Page<ProblemVo> problemVoPage = problemService.listAll(problemQueryRequest);
        return Result.ok(problemVoPage);
    }


    /**
     * 获取所有题目列表
     * @return Result<ProblemVo>
     */
    @Operation(summary = "根据id获取题目详情")
    @GetMapping("/selectById/{id}")
    public Result<ProblemVo> selectById(@PathVariable("id") Long id) {
        ProblemVo problemVo =  problemService.selectById(id);
        return Result.ok(problemVo);
    }

}
